package com.mzpai.web.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.mzpai.board.model.OperateCashLog;
import com.mzpai.board.model.OperateFlowLog;
import com.mzpai.board.service.OperateCashLogService;
import com.mzpai.board.service.OperateFlowLogService;
import com.mzpai.board.service.exception.BoardResException;
import com.mzpai.board.service.exception.BoardResExceptionCode;
import com.mzpai.board.vo.OperateCashLogReqVo;
import com.mzpai.board.vo.OperateFlowLogReqVo;
import com.mzpai.board.vo.OperateOneDayCashLogDetailVo;
import com.mzpai.board.vo.OperateOneDayCashLogVo;
import com.mzpai.board.vo.OperateOneDayFlowLogDetailVo;
import com.mzpai.board.vo.OperateOneDayFlowLogVo;
import com.mzpai.board.vo.OperateSomeDayCashLogDetailVo;
import com.mzpai.board.vo.OperateSomeDayCashLogVo;
import com.mzpai.board.vo.OperateSomeDayFlowLogDetailVo;
import com.mzpai.board.vo.OperateSomeDayFlowLogVo;
import com.mzpai.util.BeanUtils;
import com.mzpai.util.DateUtil;
import com.mzpai.util.StringUtils;
import com.mzpai.vo.ResponseVo;
import com.mzpai.web.handler.BoardHandlerUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@Api(value = "看板控制类")
@RestController
@RequestMapping("/board")
public class BoardController {
	
	 protected Logger logger = LoggerFactory.getLogger(BoardController.class);
	 
	@Autowired
	private OperateCashLogService operateCashLogService;
	@Autowired
	private OperateFlowLogService operateFlowLogService;
	
	@ApiOperation(value = "获取某一天的流量数据,展示流量曲线图")
    @RequestMapping(value = "/queryFlowLog", method = RequestMethod.POST)
    public ResponseVo<List<OperateOneDayFlowLogVo>> queryFlowLog(
    		@ApiParam(required = true, name = "operateFlowReqVo", value = "入参为[operateFlowReqVo]对象")
	        @RequestBody OperateFlowLogReqVo operateFlowReqVo ){
		
		logger.info("msg1=获取某一天的流量数据,展示流量曲线图,,method=queryFlowLog,,operateFlowReqVo={}",JSON.toJSONString(operateFlowReqVo));
		String startDateStr=operateFlowReqVo.getStartDate();
		if(StringUtils.isNullOrBlank(startDateStr)){
			throw new BoardResException(BoardResExceptionCode.START_TIME_NULL.getCode(),BoardResExceptionCode.START_TIME_NULL.getMessage());
		}
		List<OperateFlowLog> operateFlowLogList=operateFlowLogService.getFlowLogListGroupByKindCodeCreateTime(operateFlowReqVo);
		
		List<OperateOneDayFlowLogVo> operateOneDayFlowLogList=new ArrayList<OperateOneDayFlowLogVo>();
		if(operateFlowLogList!=null && !operateFlowLogList.isEmpty()){
			for(OperateFlowLog opFlowLog:operateFlowLogList){
				OperateOneDayFlowLogVo oneDayFlowDetailVo=new OperateOneDayFlowLogVo();
				BeanUtils.copyProperties(opFlowLog, oneDayFlowDetailVo);
				operateOneDayFlowLogList.add(oneDayFlowDetailVo);
			}
		}
		ResponseVo<List<OperateOneDayFlowLogVo>> operateFlowLogRes=new ResponseVo<List<OperateOneDayFlowLogVo>>();
		operateFlowLogRes.setResult(operateOneDayFlowLogList);
    	return operateFlowLogRes;
    }
	
	@ApiOperation(value = "获取某一天流量数据明细,展示明细图表")
    @RequestMapping(value = "/queryFlowDayDetail", method = RequestMethod.POST)
    public ResponseVo<List<OperateOneDayFlowLogDetailVo>> queryFlowDayDetail(
    		@ApiParam(required = true, name = "operateFlowReqVo", value = "入参为[operateFlowReqVo]对象")
	        @RequestBody OperateFlowLogReqVo operateFlowReqVo ){
		
		logger.info("msg1=获取某一天流量数据明细,展示明细图表,,method=queryFlowDayDetail,,operateFlowReqVo={}",JSON.toJSONString(operateFlowReqVo));
		
		String startDateStr=operateFlowReqVo.getStartDate();
		if(StringUtils.isNullOrBlank(startDateStr)){
			throw new BoardResException(BoardResExceptionCode.START_TIME_NULL.getCode(),BoardResExceptionCode.START_TIME_NULL.getMessage());
		}
		List<OperateFlowLog> operateFlowLogList=operateFlowLogService.getFlowLogListGroupByStoreIdKindCodeCreateTime(operateFlowReqVo);
		Map<String,OperateOneDayFlowLogDetailVo> storeIdMap=new HashMap<String,OperateOneDayFlowLogDetailVo>();
		List<OperateOneDayFlowLogDetailVo> lastOneDayFlowDetailList=new ArrayList<OperateOneDayFlowLogDetailVo>();
		
		//统计平台总数
		OperateFlowLogReqVo queryOperateFlowReqVo=new OperateFlowLogReqVo();
		queryOperateFlowReqVo.setStartDate(operateFlowReqVo.getStartDate());
		List<OperateFlowLog> queryOperateFlowLogList=operateFlowLogService.getFlowLogListGroupByKindCodeCreateTime(queryOperateFlowReqVo);
		OperateOneDayFlowLogDetailVo plateFormDayFlowDetailVo=BoardHandlerUtil.countOneDayFlowLogPlateFormTotal(operateFlowReqVo,queryOperateFlowLogList);
		lastOneDayFlowDetailList.add(plateFormDayFlowDetailVo);
		
		for(OperateFlowLog flowLog:operateFlowLogList){
			String storeId=flowLog.getStoreId();
			String stroeName=flowLog.getStoreName();
			String kindCode=flowLog.getKindCode();
			int total=flowLog.getTotal();
			int lastWeekTotal=flowLog.getLastWeekTotal();
			int lastDayTotal=flowLog.getLastDayTotal();
			
			//只筛选 门店storeid不是空的
			if(!StringUtils.isNullOrBlank(storeId) && !"0".equals(storeId)){
				OperateOneDayFlowLogDetailVo getMapFlowDetail=storeIdMap.get(storeId);
				if(getMapFlowDetail!=null){
					Map<String,String> mapDetail=getMapFlowDetail.getMapDetail();
					mapDetail.put(kindCode, total+","+lastWeekTotal+","+lastDayTotal);
				}else{
					OperateOneDayFlowLogDetailVo oneDayFlowDetailVo=new OperateOneDayFlowLogDetailVo();
					oneDayFlowDetailVo.setStoreId(storeId);
					oneDayFlowDetailVo.setStoreName(stroeName);
					Map<String,String> mapDetail=new HashMap<String,String>();
					mapDetail.put(kindCode, total+","+lastWeekTotal+","+lastDayTotal);
					oneDayFlowDetailVo.setMapDetail(mapDetail);
					storeIdMap.put(storeId, oneDayFlowDetailVo);
					lastOneDayFlowDetailList.add(oneDayFlowDetailVo);
				}
			}
			
		}
		ResponseVo<List<OperateOneDayFlowLogDetailVo>> operateFlowLogRes=new ResponseVo<List<OperateOneDayFlowLogDetailVo>>();
		operateFlowLogRes.setResult(lastOneDayFlowDetailList);
    	return operateFlowLogRes;
    }
	
	
	
	
	@ApiOperation(value = "获取某些天的流量数据,展示曲线图")
    @RequestMapping(value = "/queryFlowPeriodLog", method = RequestMethod.POST)
    public ResponseVo<List<OperateSomeDayFlowLogVo>> queryFlowPeriodLog(
    		@ApiParam(required = true, name = "operateFlowReqVo", value = "入参为[operateFlowReqVo]对象")
	        @RequestBody OperateFlowLogReqVo operateFlowReqVo ){
		
		logger.info("msg1=获取某些天的流量数据,展示曲线图,,method=queryFlowPeriodLog,,operateFlowReqVo={}",JSON.toJSONString(operateFlowReqVo));
		
		String startDateStr=operateFlowReqVo.getStartDate();
		String endDateStr=operateFlowReqVo.getEndDate();
		
		if(StringUtils.isNullOrBlank(startDateStr)){
			throw new BoardResException(BoardResExceptionCode.START_TIME_NULL.getCode(),BoardResExceptionCode.START_TIME_NULL.getMessage());
		}
		if(StringUtils.isNullOrBlank(endDateStr)){
			throw new BoardResException(BoardResExceptionCode.END_TIME_NULL.getCode(),BoardResExceptionCode.END_TIME_NULL.getMessage());
		}
		
		List<OperateFlowLog> operateFlowLogList=operateFlowLogService.getFlowLogListGroupByKindCodeCreateTime(operateFlowReqVo);
        
		//operateSomeDayFlowList 按kindcode和时间归类
		Map<String,OperateSomeDayFlowLogVo> kindCodeMap=new HashMap<String,OperateSomeDayFlowLogVo>();
		List<OperateSomeDayFlowLogVo> lastSomeDayFlowList=new ArrayList<OperateSomeDayFlowLogVo>();
		for(OperateFlowLog flowLog:operateFlowLogList){
			Date createTime=flowLog.getCreateTime();
			String createTimeStr=DateUtil.formatDate(createTime, DateUtil.DATE);
			String kindCode=flowLog.getKindCode();
			
			int total=flowLog.getTotal();
			OperateSomeDayFlowLogVo getMapFlowLog=kindCodeMap.get(kindCode);
			if(getMapFlowLog!=null){
				Map<String,Integer> mapDetail=getMapFlowLog.getMapDetail();
				mapDetail.put(createTimeStr, total);
			}else{
				OperateSomeDayFlowLogVo someDayFlowLog=new OperateSomeDayFlowLogVo();
				someDayFlowLog.setKindCode(kindCode);
				Map<String,Integer> mapDetail=new HashMap<String,Integer>();
				mapDetail.put(createTimeStr, total);
				someDayFlowLog.setMapDetail(mapDetail);
				kindCodeMap.put(kindCode, someDayFlowLog);
				lastSomeDayFlowList.add(someDayFlowLog);
			}
		}
		logger.info("msg1=获取某些天的流量数据,展示曲线图结束,,method=queryFlowPeriodLog,,size={}",lastSomeDayFlowList.size());

		ResponseVo<List<OperateSomeDayFlowLogVo>> operateFlowLogRes=new ResponseVo<List<OperateSomeDayFlowLogVo>>();
		operateFlowLogRes.setResult(lastSomeDayFlowList);
    	return operateFlowLogRes;
    }
	
	
	@ApiOperation(value = "获取某些天的流量数据明细,展示图表")
    @RequestMapping(value = "/queryFlowPeriodDetail", method = RequestMethod.POST)
    public ResponseVo<List<OperateSomeDayFlowLogDetailVo>> queryFlowPeriodDetail(
    		@ApiParam(required = true, name = "operateFlowReqVo", value = "入参为[operateFlowReqVo]对象")
	        @RequestBody OperateFlowLogReqVo operateFlowReqVo ){
		
		logger.info("msg1=获取某些天的流量数据明细,展示图表,,method=queryFlowPeriodDetail,,operateFlowReqVo={}",JSON.toJSONString(operateFlowReqVo));
		
		String startDateStr=operateFlowReqVo.getStartDate();
		String endDateStr=operateFlowReqVo.getEndDate();
		
		if(StringUtils.isNullOrBlank(startDateStr)){
			throw new BoardResException(BoardResExceptionCode.START_TIME_NULL.getCode(),BoardResExceptionCode.START_TIME_NULL.getMessage());
		}
		if(StringUtils.isNullOrBlank(endDateStr)){
			throw new BoardResException(BoardResExceptionCode.END_TIME_NULL.getCode(),BoardResExceptionCode.END_TIME_NULL.getMessage());
		}
		List<OperateFlowLog> operateFlowLogList=operateFlowLogService.getFlowLogListGroupByKindCodeCreateTime(operateFlowReqVo);
		
		//OperateFlowLog日期归类
		Map<String,OperateSomeDayFlowLogDetailVo> createTimeMap=new HashMap<String,OperateSomeDayFlowLogDetailVo>();
		List<OperateSomeDayFlowLogDetailVo> lastSomeDayFlowDetailList=new ArrayList<OperateSomeDayFlowLogDetailVo>();
		for(OperateFlowLog flowLog:operateFlowLogList){
			Date createTime=flowLog.getCreateTime();
			String createTimeStr=DateUtil.formatDate(createTime, DateUtil.DATE);
			String kindCode=flowLog.getKindCode();
			int total=flowLog.getTotal();
			int lastWeekTotal=flowLog.getLastWeekTotal();
			int lastDayTotal=flowLog.getLastDayTotal();
			
			OperateSomeDayFlowLogDetailVo getMapFlowDetail=createTimeMap.get(createTimeStr);
			if(getMapFlowDetail!=null){
				Map<String,String> mapDetail=getMapFlowDetail.getMapDetail();
				mapDetail.put(kindCode, total+","+lastWeekTotal+","+lastDayTotal);
			}else{
				OperateSomeDayFlowLogDetailVo someDayFlowDetailVo=new OperateSomeDayFlowLogDetailVo();
				someDayFlowDetailVo.setCreateTime(createTimeStr);
				Map<String,String> mapDetail=new HashMap<String,String>();
				mapDetail.put(kindCode, total+","+lastWeekTotal+","+lastDayTotal);
				someDayFlowDetailVo.setMapDetail(mapDetail);
				createTimeMap.put(createTimeStr, someDayFlowDetailVo);
				lastSomeDayFlowDetailList.add(someDayFlowDetailVo);
			}
		}
		logger.info("msg1=获取某些天的流量数据明细,展示图表结束,,method=queryFlowPeriodDetail,,size={}",lastSomeDayFlowDetailList.size());

		ResponseVo<List<OperateSomeDayFlowLogDetailVo>> operateFlowLogRes=new ResponseVo<List<OperateSomeDayFlowLogDetailVo>>();
		operateFlowLogRes.setResult(lastSomeDayFlowDetailList);
    	return operateFlowLogRes;
    }
	
	
	@ApiOperation(value = "获取某一天的交易数据,展示现金曲线图")
    @RequestMapping(value = "/queryCashLog", method = RequestMethod.POST)
    public ResponseVo<List<OperateOneDayCashLogVo>> queryCashLog(
    		@ApiParam(required = true, name = "operateCashLogReqVo", value = "入参为[operateCashLogReqVo]对象")
	        @RequestBody OperateCashLogReqVo operateCashLogReqVo ){
		
		logger.info("msg1=获取某一天的交易数据,展示现金曲线图,,method=queryCashLog,,operateCashLogReqVo={}",JSON.toJSONString(operateCashLogReqVo));
		
		String startDateStr=operateCashLogReqVo.getStartDate();
		if(StringUtils.isNullOrBlank(startDateStr)){
			throw new BoardResException(BoardResExceptionCode.START_TIME_NULL.getCode(),BoardResExceptionCode.START_TIME_NULL.getMessage());
		}
		List<OperateCashLog> operateCashLogList=operateCashLogService.getCashLogListGroupByKindCodeCreateTime(operateCashLogReqVo);
		
		List<OperateOneDayCashLogVo> operateOneDayCashLogList=new ArrayList<OperateOneDayCashLogVo>();
		
		if(operateCashLogList!=null && !operateCashLogList.isEmpty()){
			for(OperateCashLog operateCashLog:operateCashLogList){
				OperateOneDayCashLogVo oneDayCashDetailVo=new OperateOneDayCashLogVo();
				BeanUtils.copyProperties(operateCashLog, oneDayCashDetailVo);
//				BoardHandlerUtil.setPrecision(oneDayCashDetailVo);
				operateOneDayCashLogList.add(oneDayCashDetailVo);
			}
		}
		logger.info("msg1=获取某一天的交易数据,展示现金曲线图结束,,method=queryCashLog,,size={}",operateOneDayCashLogList.size());

		ResponseVo<List<OperateOneDayCashLogVo>> operateFlowLogRes=new ResponseVo<List<OperateOneDayCashLogVo>>();
		operateFlowLogRes.setResult(operateOneDayCashLogList);
    	return operateFlowLogRes;
    }
	
	
	
	@ApiOperation(value = "获取某一天的交易数据明细,展示现金图表")
    @RequestMapping(value = "/queryCashDayDetail", method = RequestMethod.POST)
    public ResponseVo<List<OperateOneDayCashLogDetailVo>> queryCashDayDetail(
    		@ApiParam(required = true, name = "operateFlowReqVo", value = "入参为[operateFlowReqVo]对象")
	        @RequestBody OperateCashLogReqVo operateCashLogReqVo){
		
		logger.info("msg1=获取某一天的交易数据明细,展示现金图表,,method=queryCashDayDetail,,operateCashLogReqVo={}",JSON.toJSONString(operateCashLogReqVo));
		
		String startDateStr=operateCashLogReqVo.getStartDate();
		if(StringUtils.isNullOrBlank(startDateStr)){
			throw new BoardResException(BoardResExceptionCode.START_TIME_NULL.getCode(),BoardResExceptionCode.START_TIME_NULL.getMessage());
		}
		List<OperateCashLog> operateCashLogList=operateCashLogService.getCashLogListGroupByStoreIdKindCodeCreateTime(operateCashLogReqVo);
		//operateSomeDayFlowList 按门店归类
		Map<String,OperateOneDayCashLogDetailVo> storeIdMap=new HashMap<String,OperateOneDayCashLogDetailVo>();
		List<OperateOneDayCashLogDetailVo> lastOneDayCashDetailList=new ArrayList<OperateOneDayCashLogDetailVo>();
		
		//统计平台汇总
		OperateCashLogReqVo queryOperateCashLogReqVo=new OperateCashLogReqVo();
		queryOperateCashLogReqVo.setStartDate(operateCashLogReqVo.getStartDate());
		List<OperateCashLog> qeryOperateCashLogList=operateCashLogService.getCashLogListGroupByKindCodeCreateTime(queryOperateCashLogReqVo);
		OperateOneDayCashLogDetailVo plateFormDayCashDetailVo=BoardHandlerUtil.countOperateOneDayCashLogPlateFormTotal(operateCashLogReqVo,qeryOperateCashLogList);
		lastOneDayCashDetailList.add(plateFormDayCashDetailVo);
				
		for(OperateCashLog cashLog:operateCashLogList){
			String storeId=cashLog.getStoreId();
			String stroeName=cashLog.getStoreName();
			String kindCode=cashLog.getKindCode();
			Double total=cashLog.getTotal();
			Double lastWeekTotal=cashLog.getLastWeekTotal();
			Double lastDayTotal=cashLog.getLastDayTotal();
			
			if(!StringUtils.isNullOrBlank(storeId) && !"0".equals(storeId)){
				OperateOneDayCashLogDetailVo getMapCashDetail=storeIdMap.get(storeId);
				if(getMapCashDetail!=null){
					Map<String,String> mapDetail=getMapCashDetail.getMapDetail();
					mapDetail.put(kindCode, total+","+lastWeekTotal+","+lastDayTotal);
				}else{
					OperateOneDayCashLogDetailVo oneDayCashDetailVo=new OperateOneDayCashLogDetailVo();
					oneDayCashDetailVo.setStoreId(storeId);
					oneDayCashDetailVo.setStoreName(stroeName);
					Map<String,String> mapDetail=new HashMap<String,String>();
					mapDetail.put(kindCode, total+","+lastWeekTotal+","+lastDayTotal);
					oneDayCashDetailVo.setMapDetail(mapDetail);
					storeIdMap.put(storeId, oneDayCashDetailVo);
					lastOneDayCashDetailList.add(oneDayCashDetailVo);
				}
			}
			
		}
		logger.info("msg1=获取某一天的交易数据明细,展示现金图表结束,,method=queryCashDayDetail,,size={}",lastOneDayCashDetailList.size());

		ResponseVo<List<OperateOneDayCashLogDetailVo>> operateCashLogRes=new ResponseVo<List<OperateOneDayCashLogDetailVo>>();
		operateCashLogRes.setResult(lastOneDayCashDetailList);
    	return operateCashLogRes;
    }
	
	
	
	
	@ApiOperation(value = "获取某些天的交易数据,展示现金曲线图")
    @RequestMapping(value = "/queryCashPeriodLog", method = RequestMethod.POST)
    public ResponseVo<List<OperateSomeDayCashLogVo>> queryCashPeriodLog(
    		@ApiParam(required = true, name = "operateCashLogReqVo", value = "入参为[operateCashLogReqVo]对象")
	        @RequestBody OperateCashLogReqVo operateCashLogReqVo){
		
		
		logger.info("msg1=获取某些天的交易数据,展示现金曲线图,,method=queryCashPeriodLog,,operateCashLogReqVo={}",JSON.toJSONString(operateCashLogReqVo));
		
		String startDateStr=operateCashLogReqVo.getStartDate();
		String endDateStr=operateCashLogReqVo.getEndDate();
		
		if(StringUtils.isNullOrBlank(startDateStr)){
			throw new BoardResException(BoardResExceptionCode.START_TIME_NULL.getCode(),BoardResExceptionCode.START_TIME_NULL.getMessage());
		}
		if(StringUtils.isNullOrBlank(endDateStr)){
			throw new BoardResException(BoardResExceptionCode.END_TIME_NULL.getCode(),BoardResExceptionCode.END_TIME_NULL.getMessage());
		}
		
        List<OperateCashLog> operateCashLogList=operateCashLogService.getCashLogListGroupByKindCodeCreateTime(operateCashLogReqVo);
        
		//operateSomeDayFlowList 按kindcode和时间归类
		Map<String,OperateSomeDayCashLogVo> kindCodeMap=new HashMap<String,OperateSomeDayCashLogVo>();
		List<OperateSomeDayCashLogVo> lastSomeDayCashList=new ArrayList<OperateSomeDayCashLogVo>();
		for(OperateCashLog cashLog:operateCashLogList){
			Date createTime=cashLog.getCreateTime();
			String createTimeStr=DateUtil.formatDate(createTime, DateUtil.DATE);
			String kindCode=cashLog.getKindCode();
			Double total=cashLog.getTotal();
			OperateSomeDayCashLogVo getMapCashLog=kindCodeMap.get(kindCode);
			if(getMapCashLog!=null){
				Map<String,Double> mapDetail=getMapCashLog.getMapDetail();
				mapDetail.put(createTimeStr, total);
			}else{
				OperateSomeDayCashLogVo someDayCashLog=new OperateSomeDayCashLogVo();
				someDayCashLog.setKindCode(kindCode);
				Map<String,Double> mapDetail=new HashMap<String,Double>();
				mapDetail.put(createTimeStr, total);
				someDayCashLog.setMapDetail(mapDetail);
				kindCodeMap.put(kindCode, someDayCashLog);
				lastSomeDayCashList.add(someDayCashLog);
			}
		}
		logger.info("msg1=获取某些天的交易数据,展示现金曲线图结束,,method=queryCashPeriodLog,,size={}",lastSomeDayCashList.size());
		ResponseVo<List<OperateSomeDayCashLogVo>> operateCashLogRes=new ResponseVo<List<OperateSomeDayCashLogVo>>();
		operateCashLogRes.setResult(lastSomeDayCashList);
    	return operateCashLogRes;
    }
	
	@ApiOperation(value = "获取某些天的交易数据明细,展示现金图表")
    @RequestMapping(value = "/queryCashPeriodDetail", method = RequestMethod.POST)
    public ResponseVo<List<OperateSomeDayCashLogDetailVo>> queryCashPeriodDetail(
    		@ApiParam(required = true, name = "operateCashLogReqVo", value = "入参为[operateCashLogReqVo]对象")
	        @RequestBody OperateCashLogReqVo operateCashLogReqVo){
		
		logger.info("msg1=获取某些天的交易数据明细,展示现金图表开始,,method=queryCashPeriodDetail,,operateCashLogReqVo={}",JSON.toJSONString(operateCashLogReqVo));
		
		String startDateStr=operateCashLogReqVo.getStartDate();
		String endDateStr=operateCashLogReqVo.getEndDate();
		
		if(StringUtils.isNullOrBlank(startDateStr)){
			throw new BoardResException(BoardResExceptionCode.START_TIME_NULL.getCode(),BoardResExceptionCode.START_TIME_NULL.getMessage());
		}
		if(StringUtils.isNullOrBlank(endDateStr)){
			throw new BoardResException(BoardResExceptionCode.END_TIME_NULL.getCode(),BoardResExceptionCode.END_TIME_NULL.getMessage());
		}
		List<OperateCashLog> operateCashLogList=operateCashLogService.getCashLogListGroupByKindCodeCreateTime(operateCashLogReqVo);
		
		//OperateFlowLog日期归类
		Map<String,OperateSomeDayCashLogDetailVo> createTimeMap=new HashMap<String,OperateSomeDayCashLogDetailVo>();
		List<OperateSomeDayCashLogDetailVo> lastSomeDayCashDetailList=new ArrayList<OperateSomeDayCashLogDetailVo>();
		
		for(OperateCashLog cashLog:operateCashLogList){
			Date createTime=cashLog.getCreateTime();
			String createTimeStr=DateUtil.formatDate(createTime, DateUtil.DATE);
			String kindCode=cashLog.getKindCode();
			Double total=cashLog.getTotal();
			Double lastWeekTotal=cashLog.getLastWeekTotal();
			Double lastDayTotal=cashLog.getLastDayTotal();
			
			OperateSomeDayCashLogDetailVo getMapFlowDetail=createTimeMap.get(createTimeStr);
			if(getMapFlowDetail!=null){
				Map<String,String> mapDetail=getMapFlowDetail.getMapDetail();
				mapDetail.put(kindCode, total+","+lastWeekTotal+","+lastDayTotal);
			}else{
				OperateSomeDayCashLogDetailVo someDayCashDetailVo=new OperateSomeDayCashLogDetailVo();
				someDayCashDetailVo.setCreateTime(createTimeStr);
				Map<String,String> mapDetail=new HashMap<String,String>();
				mapDetail.put(kindCode, total+","+lastWeekTotal+","+lastDayTotal);
				someDayCashDetailVo.setMapDetail(mapDetail);
				createTimeMap.put(createTimeStr, someDayCashDetailVo);
				lastSomeDayCashDetailList.add(someDayCashDetailVo);
			}
		}
		logger.info("msg1=获取某些天的交易数据明细,展示现金图表结束,,method=queryCashPeriodDetail,,size={}",lastSomeDayCashDetailList.size());
		ResponseVo<List<OperateSomeDayCashLogDetailVo>> operateCashLogRes=new ResponseVo<List<OperateSomeDayCashLogDetailVo>>();
		operateCashLogRes.setResult(lastSomeDayCashDetailList);
    	return operateCashLogRes;
    }
	
	
	
}
